package com.neuedu.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ercai
 * @date 2019/7/31 - 18:43
 */
public class DateUtils {

    //日期转换成字符串
    public static String dateToString(Date date, String patt){

        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        String s = sdf.format(date);
        return s;
    }

    //字符串转换成日期
    public static Date stringToDate(String s,String patt) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        Date date = sdf.parse(s);
        return date;
    }
}
